﻿using B.S.Data.MES.API.Applications.QualityManagement.ExamineMaterialsCommand.Commands;
using B.S.Domain.BasicData.MaterialManagement.Product_material;
using B.S.Infratrctrue;
using B.S.Requst;
using MediatR;

namespace B.S.Data.MES.API.Applications.QualityManagement.ExamineMaterialsCommand.CommandHandlers
{
    public class ShowProduct_materialCommandHandler : IRequestHandler<ShowProduct_materialCommand, APIRequst<List<Product_material>>>
    {

        private readonly IBaseRepository<Product_material> _examinematerRepository;
        public ShowProduct_materialCommandHandler(IBaseRepository<Product_material> examinematerRepository)
        {
            _examinematerRepository = examinematerRepository;
        }
        public Task<APIRequst<List<Product_material>>> Handle(ShowProduct_materialCommand request, CancellationToken cancellationToken)
        {
            var list = _examinematerRepository.GetAll();

            return Task.FromResult(new APIRequst<List<Product_material>>
            {
                Data = list.ToList(),
                Code = RequstCode.成功,
                Msg = RequstCode.成功.ToString()

            });

        }
    }
}
